clear
set more off
log using "\\file\UsersW$\wrr15\Home\My Documents\My Files\ATANDA AKINWANDE\BCD PAPER\HEALTH ECONOMICS revision\NEW DATA AND PROGRAMS (20171021)\TABLE5top.smcl", replace
use "\\file\UsersW$\wrr15\Home\My Documents\My Files\ATANDA AKINWANDE\BCD PAPER\HEALTH ECONOMICS revision\NEW DATA AND PROGRAMS (20171021)\BEA_BCD_Dataset_stata.dta"

//*****************NOTE*******************************************************************************////
//** N = 14; T = 69; 																				**////
//** Before stacking the data for each variable by industry, the matrix dimension is 69 x 14.		**////
//** Excluding allprod with 69 x 1 dimension; allprod = industry_wide productivity measure. 		**////
//** The presented data for allprod here is the same for each industry. It is generated as:			**////
//** allprod = kronecker product of industry_wide productivity (69 x 1) with matrix of ones (1 x 14)**////
//****************************************************************************************************////
//**									NOTE FOR CCEMG ESTIMATION: 
//** Cross-averages of the dependent and independent variables are used as additional covariates to 
//** account for unobserved common factors. For the BEA dataset, the industry wide productivity 
//** (allprod) does not vary across industry. Unlike the OECD dataset where economy-wide productivity 
//** vary across country. In the case of BEA, the average of allprod (independent variable) across 
//** industry (Avg_allprod) is the same as allprod i.e. allprod == Avg_allprod. Therefore, creating a 
//** perfect collinearity betweent the independent variable (allprod) and Avg_allprod (that account 
//** for common factor). Our type of model set-up is best estimated using GAUSS not STATA since the 
//** independent variables does vary across industry.
//****************************************************************************************************////

xtset cid year
summarize lil pip allprod prodi

gen llil = log(lil)
gen lallprod = log(allprod)

////Panel Series CD Test
xtcd lil pip prodi

//Heterogeneous Slopes Estimators with Group-Specific Trends//

//LHL Model //
xtmg llil lallprod, aug trend full res(let3)
matrix list e(betas)


//Price Model //
xtmg pip allprod, aug trend full res(pet3)
matrix list e(betas)

log close

